﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace GameEngine
{
    class Spieler
    {
        public Texture2D Back;
        public Texture2D Front;
        Weapon[] Waffen;

        public void Init()
        {

        }

        public void LoadContent(ContentManager Content)
        {
            Waffen = new Weapon[1];
            Back = Content.Load<Texture2D>(@"Spieler\Robot_Wheels");
            Front = Content.Load<Texture2D>(@"Spieler\Body\Robot_Body_Yellow");
            Waffen[0] = new Weapon();
            Waffen[0].Texturs = Content.Load<Texture2D>(@"Spieler\Weapons\Robot_Weapon_Rocket-Launcher");
            Waffen[0].ListeKugeln = new List<Bullet>();
            Waffen[0].Kugel = Content.Load<Texture2D>(@"Kugel1");
            Waffen[0].LifetimeBullet = 50;
        }

        public void Update()
        {
            Waffen[0].Update(new Vector2(512, 362), Input.Richtung(), new List<Rectangle>(), Input.Movement.X, Input.Movement.Y);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();

            double angle = Math.Atan2(362+50 - GameEngine.Input.MS.Y ,512+50 - GameEngine.Input.MS.X);


            spriteBatch.Draw(Back, new Vector2(512 , 362 ), null, Color.White, 0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0f);    
            //spriteBatch.Draw(Back, new Vector2(512, 362), null, Color.White, (float)MathHelper.ToRadians(Input.Richtung() * 45f), Vector2.Zero, 0.5f, SpriteEffects.None, 0f);     
            Waffen[0].Draw(spriteBatch, new Vector2(512, 362));
            spriteBatch.Draw(Front, new Vector2(512 +50, 362+50), null, Color.White, (float)angle - MathHelper.ToRadians(90f), new Vector2(Front.Width/2), 0.5f, SpriteEffects.None, 0f);
            spriteBatch.End();
        }
        
    }
}
